package com.jsu.information.controller.v1;


import io.swagger.annotations.Api;
import com.jsu.information.service.impl.DownloadServiceImpl;
import io.swagger.annotations.ApiOperation;
import org.example.model.common.dtos.ResponseResult;
import org.example.model.information.pojo.Download;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/information/web/v1/download")
@Api(tags = "下载资料控制器")
public class DownloadController {
    @Autowired
    private DownloadServiceImpl downloadService;

    @ApiOperation(value = "获取下载资料信息")
    @GetMapping("/get/{id}")
    public ResponseResult getDownload(@PathVariable Integer id){
        return downloadService.getDownload(id);
    }

    @ApiOperation(value = "获取所有下载资料信息")
    @GetMapping("/get/all")
    public ResponseResult getAllDownload(){
        return downloadService.getAllDownload();
    }

    @ApiOperation(value = "添加下载资料信息")
    @PostMapping("/add")
    public ResponseResult addDownload(@RequestBody Download download){
        return downloadService.addDownload(download);
    }

    @ApiOperation(value = "删除下载资料信息")
    @DeleteMapping("/delete/{id}")
    public ResponseResult deleteDownload(@PathVariable Integer id){
        return downloadService.deleteDownload(id);
    }

    @ApiOperation(value = "更新下载资料信息")
    @PostMapping("/update")
    public ResponseResult updateDownload(@RequestBody Download download){
        return downloadService.updateDownload(download);
    }

    //TODO

    @ApiOperation(value = "上传下载资料信息")
    @PostMapping("/upload")
    public ResponseResult uploadExcel(@RequestParam("file") MultipartFile file) {
        return downloadService.uploadExcel(file);
    }

    @ApiOperation(value = "导出下载资料信息")
    @GetMapping("/export")
    public ResponseResult exportExcel(@RequestParam("fileName") String fileName) {
        return downloadService.exportExcel(fileName);
    }


}
